package com.example.hotelmanager.widget;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.example.hotelmanager.R;
import com.example.hotelmanager.ui.activity.LoginActivity;

public class LeftMenuFragment extends Fragment {

	private View leftMenu;

	private RelativeLayout bookHotelLayout;

	private RelativeLayout msgLayout;

	private RelativeLayout myOrderLayout;

	private RelativeLayout myFavLayout;

	private RelativeLayout selfMsgLayout;

	private RelativeLayout myPacketsLayout;

	private RelativeLayout mySharedLayout;

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// 加载left-menu view
		leftMenu = inflater.inflate(R.layout.left_menu_content, null);

		initView();

		return leftMenu;
	}

	void initView() {
		bookHotelLayout = (RelativeLayout) leftMenu
				.findViewById(R.id.left_book_hotel_layout);
		msgLayout = (RelativeLayout) leftMenu
				.findViewById(R.id.left_msg_layout);
		myOrderLayout = (RelativeLayout) leftMenu
				.findViewById(R.id.left_my_order_layout);
		myFavLayout = (RelativeLayout) leftMenu
				.findViewById(R.id.left_my_fav_layout);
		selfMsgLayout = (RelativeLayout) leftMenu
				.findViewById(R.id.left_self_msg_layout);
		myPacketsLayout = (RelativeLayout) leftMenu
				.findViewById(R.id.left_my_packets_layout);
		mySharedLayout = (RelativeLayout) leftMenu
				.findViewById(R.id.left_my_shared_layout);

		LeftMenuOnItemClick mLeftMenuOnItemClick = new LeftMenuOnItemClick();
		bookHotelLayout.setOnClickListener(mLeftMenuOnItemClick);
		msgLayout.setOnClickListener(mLeftMenuOnItemClick);
		myOrderLayout.setOnClickListener(mLeftMenuOnItemClick);
		myFavLayout.setOnClickListener(mLeftMenuOnItemClick);
		selfMsgLayout.setOnClickListener(mLeftMenuOnItemClick);
		myPacketsLayout.setOnClickListener(mLeftMenuOnItemClick);
		mySharedLayout.setOnClickListener(mLeftMenuOnItemClick);

	}

	class LeftMenuOnItemClick implements OnClickListener {

		@Override
		public void onClick(View v) {

			switch (v.getId()) {
			case R.id.left_book_hotel_layout:

				break;
			case R.id.left_msg_layout:

				break;
			case R.id.left_my_order_layout:
				Intent i = new Intent(getActivity(), LoginActivity.class);
				startActivity(i);
				break;
			case R.id.left_my_fav_layout:

				break;
			case R.id.left_self_msg_layout:

				break;
			case R.id.left_my_packets_layout:

				break;
			case R.id.left_my_shared_layout:

				break;

			default:
				break;
			}
		}

	}

	public View getLeftMenuView() {
		return leftMenu;
	}

}
